package com.zhangxiaofanfan.hotcode.fourth.third;

/**
 *
 * @date 2024-07-13 03:14:13
 * @author zhangxiaofanfan
 */
public class HotCode081 {
    public static void main(String[] args) {
        HotCode081 hotCode = new HotCode081();
        System.out.println(hotCode.climbStairs(10));
    }

    public int climbStairs(int n) {
        if (n <= 2) {
            return n;
        }
        int[] dp = new int[] {1, 2};
        for (int i = 3; i <= n; i++) {
            int temp = dp[0] + dp[1];
            dp[0] = dp[1];
            dp[1] = temp;
        }
        return dp[1];
    }
}
